home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 25 / Cream of the Crop 25.iso / os2 / kzr0597.zip / SINH.CMD < prev    next >
OS/2 REXX Batch file  |  1997-03-06  |  3KB  |  85 lines

  1. /* REXX-Programm sinh.cmd  */
  2.  
  3.    Call RxFuncAdd 'SysLoadFuncs', RexxUtil, 'SysLoadFuncs'
  4.    Call SysLoadFuncs
  5. /*   Signal on syntax name sinhMsg */
  6.  
  7. /* Diese Variablen müssen für jede Prozedur definiert werden, damit die  */
  8. /* Prozedur die Variable bufND kennt und die Variable ND übernehmen kann.*/
  9.    Pfd=SysSearchPath("PATH", "kzr.cmd")
  10.    lp=LastPos("\", Pfd)
  11.    Pfd=DelStr(Pfd, 1+lp)
  12.    NDAsinh=Pfd||"NDAsinh.DAT"
  13.    bufND  =Pfd||"NDZahl.DAT"
  14.    bufMsg =Pfd||"Meldung.DAT"
  15.    ND = LineIn(bufND, 1)
  16.  
  17.    if ND > 450 then
  18.    do
  19.      ND=450
  20.      call charout(NDAsinh) ; Call SysFileDelete NDAsinh
  21.      ret=LineOut(NDAsinh, 450)
  22.      Call Charout,"   Achtung, nur 450 Dezimalstellen bei der Berechnung von  sinh(...)"
  23.      say
  24.      Beep(444, 200); Beep(628,300)  /* Hier kein EXIT ! */
  25.    end
  26.  
  27.    /* Wenn ND <= 450 ist, wird ND = ND  weitergegeben */
  28.    call charout(NDAsinh) ; Call SysFileDelete NDAsinh
  29.    ret=LineOut(NDAsinh, ND)
  30.  
  31.    arg x,y /* y soll "illegale" Komma's im Funktions-Argument aufspüren */
  32.    p0p=x*x /* Diese Anweisung prvoziert eine Syntax-Fehlermeldung       */
  33.  
  34.    if length(y) > 0 then
  35.    do
  36.      call charout(NDAsinh); Call SysFileDelete NDAsinh  /* hier ändern */
  37.      ret=LineOut(bufMsg, "Im Argument von  sinh(...)  ist mindestens  1  nicht zulässiges Komma !")
  38.      /* "bufMsg" und  "bufND" werden immer beim Beenden von kzr.cmd gelöscht, */
  39.      /*  damit in den diesbezüglichen temporären Dateien                      */
  40.      /*  Meldungen und ND-Werte nicht aneinandergehängt werden.               */
  41.      EXIT
  42.    end
  43.  
  44.    Numeric Digits ND+5
  45.  
  46.    if x=0 then do; y=0; Signal W; end
  47.  
  48.    if abs(x) >= 1.0E+9 then
  49.    do
  50.      call charout(NDAsinh); Call SysFileDelete NDAsinh
  51.      ret=LineOut(bufMsg, "     Der absolute Betrag des Argumentes der Funktion sinh(...)",
  52.                          "                     ",
  53.                          "darf nicht größer als  1.0E+9  sein.")
  54.   /* "bufMsg" und  "bufND" werden immer beim Beenden von kzr.cmd gelöscht, */
  55.   /*  damit in den diesbezüglichen temporären Dateien                      */
  56.   /*  Meldungen und ND-Werte nicht aneinandergehängt werden.               */
  57.      EXIT
  58.    end
  59.  
  60.    if abs(x) <  0.1 then SIGNAL A
  61.    if abs(x) >= 0.1 then SIGNAL B
  62.  
  63. A: u=1; v=1; m=2; z=x*x
  64.    do while (abs(u/v) > 10**(-ND-7))
  65.      g=z/(m*(m+1)); u=u*g; v=v+u; m=m+2; end
  66.    y=x*v; SIGNAL W
  67.  
  68. B: ep=exp(x); em=1/ep; y=(ep-em)/2
  69.  
  70. W: numeric digits ND
  71.    return(Format(y))
  72.  
  73. sinhMsg:  /* hier ändern */
  74.    sf=ErrorText(RC)
  75.    if  Pos("Bad arithmetic conversion", sf) > 0 then
  76.    do
  77.      call charout(NDAsinh); Call SysFileDelete NDAsinh  /* hier ändern */
  78.      ret=LineOut(bufMsg, "Sie haben in  sinh(...)  kein gültiges Argument eingegeben !")
  79.   /* "bufMsg" und  "bufND" werden immer beim Beenden von kzr.cmd gelöscht, */
  80.   /*  damit in den diesbezüglichen temporären Dateien                      */
  81.   /*  Meldungen und ND-Werte nicht aneinandergehängt werden.               */
  82.      EXIT
  83.    end
  84.  
  85.